package cn.kgc.springcloud.service.impl;

import cn.kgc.springcloud.entity.Tag;
import cn.kgc.springcloud.mapper.TagMapper;
import cn.kgc.springcloud.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author: mosin
 * @version: v1.0  2022/8/29
 */
@Service
public class TagServiceImpl implements TagService {

    @Autowired
    private TagMapper tagMapper;

    @Override
    public List<Tag> findAll() {
        List<Tag> tags =   tagMapper.findAll();
        return tags;
    }

    @Override
    public Tag addTag(Tag tag) {
        // 设置添加时间
        tag.setCreateDate(new Date());
       Integer line =  tagMapper.addTag(tag);
        return tag;
    }

    @Override
    public Boolean deleteTagById(Integer id) {

        Integer line =  tagMapper.deleteById(id);
        return line >0;
    }

    @Override
    public Tag findOne(Integer tagId) {

        Tag tag = tagMapper.selectById(tagId);
        return tag;
    }
}
